fix(csharp) support digit separators in binary literals and numeric type suffixes#4447
Open
sarathfrancis90 wants to merge 1 commit into
Open
fix(csharp) support digit separators in binary literals and numeric type suffixes#4447sarathfrancis90 wants to merge 1 commit into
sarathfrancis90 wants to merge 1 commit into
Conversation
…ype suffixes The C# number mode still carried a few C/C++ habits: it used ' as the digit separator, only allowed _ in decimal and hex literals, and only recognised the u/U/l/L/f/F suffixes on plain decimal literals. So 0b1010_1010 highlighted only up to the first _, 0xFFu and 1_000UL dropped their suffix, and the decimal/double suffixes m/M and d/D were missing entirely, which leaves 19.99m half-highlighted. Allowing [\d_]+ to start with an underscore also made _count (the usual private-field convention) render its leading _ as a number. Rewrote the three variants against the lexical grammar: separators sit between digits and may follow the 0x/0b prefix, integer literals take the U/L suffixes in either order, and real literals take F/D/M as well.
Build Size ReportChanges to minified artifacts in 4 files changedTotal change +26 B View Changes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #4258 — the digit-separator work in #4280 covered decimal and hex literals, but a few C# number forms are still highlighted wrong.
Changes
The number mode had kept some C/C++ habits:
'as the digit separator,_allowed only in the decimal/hex variant, and theu/U/l/Lsuffixes recognised only after a plain decimal literal. In practice that means:The last one is the one I noticed first —
[\d_]+can start with an underscore, so_count(the usual private-field convention) gets a stray highlighted_, andpoint._1highlights._1.I rewrote the three variants to follow the lexical grammar in the spec (integer literals, real literals): separators sit between digits and may also follow the
0x/0bprefix, integer literals takeU/Lin either order, and real literals takeF/D/M.Tested with a new markup fixture covering the forms above plus the two identifier cases;
npm run build && npm testis green (1579 passing), as arenpm run lintandnpm run lint-languages. The existingcsharp/floatsfixture is unchanged.Checklist
CHANGES.md